/*----------------------------------------------------------------------------
 * Copyright (c) <2019-2020>, <Huawei Technologies Co., Ltd>
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 * 1. Redistributions of source code must retain the above copyright notice, this list of
 * conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
 * of conditions and the following disclaimer in the documentation and/or other materials
 * provided with the distribution.
 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
 * to endorse or promote products derived from this software without specific prior written
 * permission.
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *---------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
 * Notice of Export Control Law
 * ===============================================
 * Huawei OMIP(belong to OMSIS) may be subject to applicable export control laws and regulations, which might
 * include those applicable to Huawei LiteOS of U.S. and the country in which you are located.
 * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such
 * applicable export control laws and regulations.
 *---------------------------------------------------------------------------*/
#ifndef __OMIP_CMD_H_
#define __OMIP_CMD_H_

#ifdef __cplusplus /* Maintain C++ compatibility */
extern "C"
{
#endif /* __cplusplus */

enum omip_vc_value{
    OMIP_VC_CHANNEL0,  /*reserved*/
    OMIP_VC_CHANNEL1,  /*reserved*/
    OMIP_VC_CHANNEL2,  /*reserved*/
    OMIP_VC_CHANNEL3,  /*reserved*/
    OMIP_VC_CHANNEL4,
    OMIP_VC_CHANNEL5,
    OMIP_VC_CHANNEL6,
    OMIP_VC_CHANNEL7,
    OMIP_VC_CHANNEL8,
    OMIP_VC_CHANNEL9,
    OMIP_VC_CHANNEL10,
    OMIP_VC_CHANNEL11,
    OMIP_VC_CHANNEL12,
    OMIP_VC_CHANNEL13,
    OMIP_VC_CHANNEL14,
    OMIP_VC_CHANNEL15,
    OMIP_VC_CHANNEL_TOTAL,
};

/*4-15 is available*/
#define OMIP_VC_CHANNEL_RESERVED  4

typedef enum
{
    MCU_UPLOAD_LOGFILE_APP = 0,
    MCU_UPLOAD_LOGFILE_GW,
} mcu_upload_logfile_direction;

typedef enum {
    OMIP_CMD_FRAME_CON,
    OMIP_CMD_FRAME_NON,
    OMIP_DATA_FRAME_CON,
    OMIP_DATA_FRAME_NON,
    OMIP_FRAME_ACK = 0xF,
    OMIP_TYPE_MAX,
}omip_frame_type;

enum omip_cmd_region{
    OMIP_SYSTEM_REGION,
    OMIP_SERVICE_REGION,
    OMIP_APPLICATION_REGION,
    OMIP_USER_DEFINED_REGION,
};

enum omip_system_sets{
    OMIP_SYSTEM_CONFIG,
    OMIP_INVALID_SYSTEM_SET = 16,
};

enum omip_service_sets{
    OMIP_SERVICE_LOCATION,
    OMIP_SERVICE_NFC,
    OMIP_SERVICE_SES,
    OMIP_SERVICE_OTA,
    OMIP_SERVICE_CNCS_NET,
    OMIP_SERVICE_CNCS_PLAT,
    OMIP_SERVICE_IOT_CARDS,
    OMIP_SERVICE_MESSAGE_PUSH,
    OMIP_INVALID_SEVICE_SET = 16,
};

enum omip_application_sets{
    OMIP_APP_HILINK0,
    OMIP_APP_HILINK1,
    OMIP_APP_HICAMPUS0 = 8,
    OMIP_APP_HICAMPUS1 = 9,
    OMIP_APP_OCEANLINK0 = 12,
    OMIP_APP_OCEANLINK1 = 13,
    OMIP_INVALID_APP_SET = 16,
};

enum omip_user_defined_sets{
    OMIP_INVALID_USER_SET = 16,
};


#define OMIP_SYS_CONFIG_CMD_FIELD     (unsigned short)(((unsigned short)OMIP_SYSTEM_REGION << 4) | (unsigned short)OMIP_SYSTEM_CONFIG)
#define OMIP_SYS_CMD_GET_VERSION      ((OMIP_SYS_CONFIG_CMD_FIELD << 8) | 0x00)
#define OMIP_SYS_CMD_CONNECT          ((OMIP_SYS_CONFIG_CMD_FIELD << 8) | 0x02)
#define OMIP_SYS_CMD_CONN_ACK         ((OMIP_SYS_CONFIG_CMD_FIELD << 8) | 0x03)


#define OMIP_HICAMPUS0_CMD_FIELD   (unsigned short)(((unsigned short)OMIP_APPLICATION_REGION << 4) | (unsigned short)OMIP_APP_HICAMPUS0)
#define OMIP_HICAMPUS1_CMD_FIELD   (unsigned short)(((unsigned short)OMIP_APPLICATION_REGION << 4) | (unsigned short)OMIP_APP_HICAMPUS1)


/* hlink region */
/* hlink region  ----->  command set */
#define HLINK_CMD_DEV_REG_REQ           ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x01)        // Device registration command
#define HLINK_CMD_FILE_MNGR_NOTICE      ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x02)        // File Management Command
#define HLINK_CMD_FILE_MNGR_BLOCK       ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x03)        // File transfer Command
#define HLINK_CMD_FILE_MNGR_BLOCK_END   ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x04)        // File transfer end command
#define HLINK_CMD_DATA_REPORT           ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x05)        // Data reporting command
#define HLINK_CMD_SRV_CMD               ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x06)        // SRV command
#define HLINK_CMD_MODULE_ONLINE         ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x07)        // Device registration request command
#define HLINK_CMD_CONNECT_BEATHEART		((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x08)
#define HLINK_CMD_BLE_FILE_MNGR_NOTICE  ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x09)        // BLE File Management Command
#define HLINK_CMD_BLE_FILE_MNGR_BLOCK   ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x0A)        // BLE File transfer Command
#define HLINK_CMD_BLE_FILE_MNGR_BLOCK_END ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x0B)        // BLE File transfer end command
#define HLINK_CMD_BLE_FILE_MNGR_ACK     (HLINK_CMD_BLE_FILE_MNGR_BLOCK | 0x80)          // BLE File transfer ack command
#define HLINK_CMD_BLE_FILE_MNGR_RESULT  ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x0C)
#define HLINK_CMD_MODULE_INFO_REQ       ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x0D)
#define HLINK_CMD_FILE_MNGR_RESPONSE   ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x05)        // File transfer response command

/* DFX trace srv value 0x280F */
#define HLINK_CMD_SRV_TRACE_CMD       ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x0F)
#define HLINK_CMD_SRV_TRACE_CMD_RSP       (HLINK_CMD_SRV_TRACE_CMD | 0x80)

/* hlink region  ----->  response set */
#define HLINK_CMD_DEV_REG_RSP           (HLINK_CMD_DEV_REG_REQ | 0x80)                   // response Device registration command
#define HLINK_CMD_FILE_MNGR_RESULT      (HLINK_CMD_FILE_MNGR_BLOCK_END | 0x80)           // response File Management Command
#define HLINK_CMD_DATA_REPORT_RSP       (HLINK_CMD_DATA_REPORT | 0x80)                   // response Data reporting command
#define HLINK_CMD_SRV_CMD_RSP           (HLINK_CMD_SRV_CMD | 0x80)                       // response SRV command
#define HLINK_CMD_MODULE_INFO_RSP       (HLINK_CMD_MODULE_INFO_REQ | 0x80)                       // response SRV command
#define HLINK_CMD_CONNECT_BEATHEART_RSP	(HLINK_CMD_CONNECT_BEATHEART | 0x80)

//srv
#define HLINK_CMD_DEV_INFO_UPDATE       ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x20)
#define HLINK_CMD_DEV_INFO_UPDATE_RSP   (HLINK_CMD_DEV_INFO_UPDATE | 0x80)
//ExtDev
#define HLINK_CMD_EXTDEV_ADD            ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x21)
#define HLINK_CMD_EXTDEV_ADD_RSP        (HLINK_CMD_EXTDEV_ADD | 0x80)
#define HLINK_CMD_EXTDEV_UPDATE         ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x22)
#define HLINK_CMD_EXTDEV_UPDATE_RSP     (HLINK_CMD_EXTDEV_UPDATE | 0x80)

//sys
#define HLINK_CMD_SET_MODULE_CONF       ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x40)
#define HLINK_CMD_SET_MODULE_CONF_RSP   (HLINK_CMD_SET_MODULE_CONF | 0x80)
#define HLINK_CMD_GET_MODULE_CONF       ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x41)
#define HLINK_CMD_GET_MODULE_CONF_RSP   (HLINK_CMD_GET_MODULE_CONF | 0x80)

#define HLINK_CMD_SYN_TIME              ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x42)
#define HLINK_CMD_SYN_TIME_RSP          (HLINK_CMD_SYN_TIME | 0x80)

#define HLINK_CMD_DEVICE_MANAGER        ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x43)
#define HLINK_CMD_DEVICE_MANAGER_RSP    (HLINK_CMD_DEVICE_MANAGER | 0x80)

#define HLINK_CMD_GET_MCU_INFO          ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x44)
#define HLINK_CMD_GET_MCU_INFO_RSP      (HLINK_CMD_GET_MCU_INFO | 0x80)
#define HLINK_CMD_ADD_DEV               ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x45)
#define HLINK_CMD_ADD_DEV_RSP           (HLINK_CMD_ADD_DEV | 0x80)
#define HLINK_CMD_GET_DEV               ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x46)
#define HLINK_CMD_GET_DEV_RSP           (HLINK_CMD_GET_DEV| 0x80) 

#define HLINK_CMD_BLE_CMD               ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x47)
#define HLINK_CMD_BLE_NOTIFY            (HLINK_CMD_BLE_CMD | 0x80)

#define HLINK_CMD_DEL_DEV               ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x48)
#define HLINK_CMD_DEL_DEV_RSP           (HLINK_CMD_DEL_DEV | 0x80)

#define HLINK_CMD_CONNECT_REQ           ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x49)  /*telephone app to mcu*/
#define HLINK_CMD_CONNECT_RSP           (HLINK_CMD_CONNECT_REQ | 0x80)             /*mcu to telephone app*/

#define HLINK_CMD_DATA_REPORT_APP 		((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x51)    // 2851  MCU->APP
#define HLINK_CMD_DATA_REPORT_APP_RSP	(HLINK_CMD_DATA_REPORT_APP | 0x80)     		// 28c1  APP->MCU

#define HLINK_CMD_BLE_DEV_MNG_REQ       ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x52)  /* between ble and mcu */
#define HLINK_CMD_BLE_DEV_MNG_RSP       (HLINK_CMD_BLE_DEV_MNG_REQ| 0x52)         /* between ble and mcu */

//inner command
#define HLINK_CMD_CONNECT_AUTH_REQ      ((OMIP_HICAMPUS0_CMD_FIELD << 8) | 0x70)   /*mcu to module*/
#define HLINK_CMD_CONNECT_AUTH_RSP      (HLINK_CMD_CONNECT_AUTH_REQ | 0x80)        /*module to mcu*/



#ifdef __cplusplus /* Maintain C++ compatibility */
}
#endif /* __cplusplus */

#endif /* UMIP_CMD_H_ */
